using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using EkRtfBase;

namespace WindowsApplication7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();                     
        }
        private Bitmap bmp;
        private void button1_Click(object sender, EventArgs e)
        {
            // Create a Bitmap image in memory and set its CompositingMode
            bmp = new Bitmap(260, 260, PixelFormat.Format32bppArgb);
            bmp.SetResolution(96, 96);
            ekRtf1.ExecuteOpen();
            bmp.Dispose();
                        
        }

        private void DrawMemoryBitmap(object Sender, EkRtfFunc.EkUDFEventArgs e)
        {
            // This is DrawMemoryBitmap user defined function ********
            Graphics gBmp = Graphics.FromImage(bmp);
            
            gBmp.CompositingMode = CompositingMode.SourceOver;

            gBmp.FillRectangle(Brushes.White, 0, 0, 259, 259);

            // draw a red circle to the bitmap in memory
            Color red = Color.FromArgb(0x70, 0xff, 0, 0);
            Brush redBrush = new SolidBrush(red);
            gBmp.FillEllipse(redBrush, 20, 20, 160, 160);

            // draw a green rectangle to the bitmap in memory
            Color green = Color.FromArgb(0x60, 0, 0xff, 0);
            Brush greenBrush = new SolidBrush(green);
            gBmp.FillRectangle(greenBrush, 90, 90, 140, 140);
            gBmp.Dispose();
            redBrush.Dispose();
            greenBrush.Dispose();
           
            e.UDFResult = bmp;
          
        }

        private void SomeText(object Sender, EkRtfFunc.EkUDFEventArgs e)
        {            
          //This is SomeText user defined function ****************
            ((EkReportVariable)e.UDFResult).AsString = "Some text";           
        }

    }
}